﻿using UnityEngine;

public class ObstacleReposition
{
    private float minY;
    private float maxY;
    private Obstacle obstacle;

    public ObstacleReposition(Obstacle _obstacle, float _minY, float _maxY)
    {
        obstacle = _obstacle;
        minY = _minY;
        maxY = _maxY;
    }

    public void reset()
    {
        obstacle.active();
        float height = getNewHeight();
        resetPositionWithHeight(height);
    }

    protected virtual float getNewHeight()
    {
        return Random.Range(minY, maxY);
    }

    private void resetPositionWithHeight(float height)
    {
        obstacle.transform.localPosition = new Vector3(0, height, 0);
    }
}
